package Guo.guowantong.springsecurity_04.service.impl;

import Guo.guowantong.springsecurity_04.dao.SysPermissionDao;
import Guo.guowantong.springsecurity_04.entity.SysPermission;
import Guo.guowantong.springsecurity_04.service.SysPermissionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (SysPermission)表服务实现类
 *
 * makejava
 * 2021-06-17 17:30:04
 */
("sysPermissionService")
public class SysPermissionServiceImpl implements SysPermissionService {
    private SysPermissionDao sysPermissionDao;
    public List<SysPermission> findAll() {
        return sysPermissionDao.findAll();
    }
    public List<SysPermission> findByAdminUserId(long userId) {
        return sysPermissionDao.findByAdminUserId(userId);
    }

    /**
     * 通过ID查询单条数据
     *
     * id 主键
     * 实例对象
     */
    @Override
    public SysPermission queryById(Long id) {
        return this.sysPermissionDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * offset 查询起始位置
     * limit 查询条数
     * 对象列表
     */
    public List<SysPermission> queryAllByLimit(int offset, int limit) {
        return this.sysPermissionDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * sysPermission 实例对象
     * 实例对象
     */
    public SysPermission insert(SysPermission sysPermission) {
        this.sysPermissionDao.insert(sysPermission);
        return sysPermission;
    }

    /**
     * 修改数据
     *
     * sysPermission 实例对象
     * 实例对象
     */
    public SysPermission update(SysPermission sysPermission) {
        this.sysPermissionDao.update(sysPermission);
        return this.queryById(sysPermission.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    public boolean deleteById(Long id) {
        return this.sysPermissionDao.deleteById(id) > 0;
    }
}